﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CompanyBussiness;

namespace Website
{
	public partial class Default : System.Web.UI.Page
	{
		protected void Page_Load(object sender, EventArgs e)
		{
            NewsManagement newsMana = new NewsManagement();
            ProductManagement proMana = new ProductManagement();
            LanguagesManagement languageMana = new LanguagesManagement();
            TurnOverService overServices = new TurnOverService();
            CompanyBussiness.Language language;
            string modulCode = "MINTRO";

            if (Request.Cookies[CONST.COOKIES_LANGUAGE] !=null )
            {
                Session[CONST.SESSION_LANGUAGE] = Request.Cookies[CONST.COOKIES_LANGUAGE][CONST.COOKIES_LANGUAGE_ID];
                language = languageMana.GetLanguageByID(int.Parse(Session[CONST.SESSION_LANGUAGE].ToString()));
                Response.Cookies[CONST.COOKIES_LANGUAGE][CONST.COOKIES_LANGUAGE_ID] = "" + language.LanguagesID;  
            }
            else
            {
                Session[CONST.SESSION_LANGUAGE] = null;
                language = languageMana.GetLanguageByCode("vi-VN");
                Response.Cookies[CONST.COOKIES_LANGUAGE][CONST.COOKIES_LANGUAGE_ID] = "" + language.LanguagesID;
            }

            //Response.Redirect("AboutUs.aspx?" + CONST.QUERYSTRING_CATEGORY + "=" + newsMana.GetTopParentCategoryID(language.LanguagesID, modulCode) + "&Mod=" + modulCode);
            Response.Redirect("~/Hem/gioi-thieu/" + newsMana.GetTopParentCategoryID(language.LanguagesID, modulCode) + "/" + modulCode + "/" + overServices.ConvertString(newsMana.GetNameCateByID(newsMana.GetTopParentCategoryID(language.LanguagesID, modulCode)).Replace(" ","-")) + ".html");
		}
	}
}